package pack1021.exception;

import java.util.InputMismatchException;
import java.util.Scanner;

// finally
public class DemoC {
    private static Scanner scan;

    static {
        scan = new Scanner(System.in);
    }

    private static void a() {
        try {
            // try书写可能出现异常的代码块
            System.out.print("请输入一个数字:");
            int number = scan.nextInt();
            System.out.println("你输入的数字是:" + number);
        } catch (ArithmeticException e) {
            System.out.println("你输入的内容不是数字，请输入数字!");
        } finally {
            System.out.println("我永远都会执行，不管发生什么！");
        }
        System.out.println("输入完毕");
    }

    private static int b() {
        int a = 1;
        try {
            return a;
        } catch (Exception e) {
            a = 3;
            return a;
        } finally {
            a++;
            return a;
        }
    }

    public static void main(String[] args) {
        int result = b();
        System.out.println(result);
    }
}